package com.hzw.code.net.json

import com.google.gson.Gson
import com.google.gson.GsonBuilder

/**
 *
 * @Author:         HuaZhongWei
 * @CreateDate:     2020/4/15 16:44
 *
 * @Description:    创建Gson对象，并适配各类型字段
 *
 */

object GsonClient {

    fun create(): Gson = GsonBuilder()
        .registerTypeAdapter(Int::class.java, IntAdapter())
        .registerTypeAdapter(Long::class.java, LongAdapter())
        .registerTypeAdapter(Double::class.java, DoubleAdapter())
        .registerTypeAdapter(Float::class.java, FloatAdapter())
        .registerTypeAdapter(String::class.java, StringAdapter())
        .create()
}